package com.sniff.atp.exception;

import com.sniff.atp.response.SniffResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class SniffExceptionHandler {

    @ExceptionHandler(BussinessException.class)
    public SniffResponse<?> handleBusinessException(BussinessException e) {
        return SniffResponse.fail(e.getCode(), e.getMsg());
    }

    @ExceptionHandler(Exception.class)
    public SniffResponse<?> handleException(Exception e) {
        log.info("系统异常：", e);
        return SniffResponse.fail("系统异常", e.getMessage());
    }
}
